package nosql.property;

import java.util.Comparator;

import nosql.util.Pair;

public class RecommendedCondition extends Pair<String, Integer> implements Comparable<RecommendedCondition>{

	public RecommendedCondition(String first, Integer second) {
		super(first, second);
	}

	@Override
	public int compareTo(RecommendedCondition o) {
		if(second < o.getSecond()){
			return -1;
		}
		else if(second == o.getSecond()){
			return 0;
		}
		else{
			return 1;
		}
	}
	
	public void increaseStrength(int increase){
		this.second += increase;
	}
	
	@Override
	public boolean equals(Object obj){
		if(obj instanceof RecommendedCondition){
			String objName = ((RecommendedCondition)obj).getFirst();
			if(first.equals(objName)){
				return true;
			}
			else{
				return false;
			}
		}
		else if(obj instanceof String){
			if(first.equals((String)obj)){
				return true;
			}
		}
		return false;
	}
}
